﻿using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DevSamPle.FormPlugin
{
    [Description("【表单插件】设置标签标题"), HotUpdate]
    public class SetLable : AbstractDynamicFormPlugIn
    {
        public override void EntityRowClick(EntityRowClickEventArgs e)
        {
            base.EntityRowClick(e);
            if (e.Key.EqualsIgnoreCase("FPOOrderEntry"))
            {
                //获取单据体总行数
                var rowCount = this.Model.GetEntryRowCount(e.Key);
                //获取单据体选中行
                var grid = this.View.GetControl<EntryGrid>(e.Key);
                var selectedRowCount = grid.GetSelectedRows().Length;
                var msg = string.Format($"{this.View.BillBusinessInfo.GetEntity(e.Key).Name}总行数:{rowCount}，选中的行数:{selectedRowCount}");
                //设置标签标题
                this.View.GetControl("F_POSW_Lable").SetCustomPropertyValue("Text", msg);
                //设置标签前景色
                this.View.GetControl("F_POSW_Lable").SetCustomPropertyValue("ForeColor", "#ff0000");
                //设置标签标题背景色
                this.View.GetControl("F_POSW_Lable").SetCustomPropertyValue("BackColor", "#ead1dc");
            }
        }
    }
}
